package com.lightboat.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler;
import com.lightboat.common.annotation.Excel;
import com.lightboat.common.core.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.SchemaProperty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.math.BigDecimal;

/**
 * 业绩计划对象 crm_performance_plan
 * 
 * @author lightboat
 * @date 2025-11-10
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(title = "业绩计划")
@TableName(value = "crm_performance_plan", autoResultMap = true)
public class CrmPerformancePlan extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    @SchemaProperty(name = "主键ID")
    @TableId
    @NotNull(groups = CrmPerformancePlan.Update.class)
    private Long id;

    /** 月份（格式：YYYY-MM） */
    @SchemaProperty(name = "月份（格式：YYYY-MM）")
    @Excel(name = "月份", readConverterExp = "格=式：YYYY-MM")
    private String month;

    /** 团队名称 */
    @SchemaProperty(name = "团队名称")
    @Excel(name = "团队名称")
    private String deptName;

    /** 团队ID */
    @SchemaProperty(name = "团队ID")
    @Excel(name = "团队ID")
    private Long deptId;

    /** 成员集合（JSON格式存储） */
    @SchemaProperty(name = "成员集合（JSON格式存储）")
    @Excel(name = "成员集合", readConverterExp = "J=SON格式存储")
    @TableField(typeHandler = Fastjson2TypeHandler.class)
    private String members;

    /** 目标金额（元） */
    @SchemaProperty(name = "目标金额（元）")
    @Excel(name = "目标金额", readConverterExp = "元=")
    private BigDecimal targetAmount;

    /** 营业额（元） */
    @SchemaProperty(name = "营业额（元）")
    @Excel(name = "营业额", readConverterExp = "元=")
    private BigDecimal turnoverAmount;

    /** 完成度（百分比） */
    @SchemaProperty(name = "完成度（百分比）")
    @Excel(name = "完成度", readConverterExp = "百=分比")
    private BigDecimal completionRate;

    /** 团队平均金额（元） */
    @SchemaProperty(name = "团队平均金额（元）")
    @Excel(name = "团队平均金额", readConverterExp = "元=")
    private BigDecimal teamAvgAmount;

    /** 全员平均金额（元） */
    @SchemaProperty(name = "全员平均金额（元）")
    @Excel(name = "全员平均金额", readConverterExp = "元=")
    private BigDecimal staffAvgAmount;

    /** 用户ID */
    @SchemaProperty(name = "用户ID")
    @Excel(name = "用户ID")
    private Long userId;

    /** 业绩类型（1个人 2团队） */
    @NotNull(groups = CrmPerformancePlan.Create.class)
    @SchemaProperty(name = "业绩类型（1个人 2团队）")
    @Excel(name = "业绩类型", readConverterExp = "1=个人,2=团队")
    private Integer performanceType;


    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("month", getMonth())
            .append("deptName", getDeptName())
            .append("deptId", getDeptId())
            .append("members", getMembers())
            .append("targetAmount", getTargetAmount())
            .append("turnoverAmount", getTurnoverAmount())
            .append("completionRate", getCompletionRate())
            .append("teamAvgAmount", getTeamAvgAmount())
            .append("staffAvgAmount", getStaffAvgAmount())
            .append("userId", getUserId())
            .append("performanceType", getPerformanceType())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}
